import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * Created by Administrator on 2017/8/4.
 */
public class testtime {
 /*   public static void main(String[] args) throws Exception {
        GregorianCalendar ca = new GregorianCalendar();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.add(Calendar.DAY_OF_MONTH, 1);
        if(ca.get(GregorianCalendar.AM_PM)==0){
            c.add(Calendar.DAY_OF_MONTH, 1);
        }else{
            c.add(Calendar.DAY_OF_MONTH, 27);
        }
        System.out.println(sf.format(c.getTime()));
    }*/
    public static void main(String[] args) throws Exception {
      GregorianCalendar ca = new GregorianCalendar();
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      Calendar c = Calendar.getInstance();
        String str1 = "2017-08-04";
        String str2 = "2018-01-03";
        Date beftime = sdf.parse(str1);
        Date afttime = sdf.parse(str2);
        Calendar bef = Calendar.getInstance();
        Calendar aft = Calendar.getInstance();
        bef.setTime(beftime);
        aft.setTime(afttime);
        int result = aft.get(Calendar.MONTH) - bef.get(Calendar.MONTH);
        System.out.println(result);
        int month = (aft.get(Calendar.YEAR) - bef.get(Calendar.YEAR)) * 12;
        System.out.println(month);
        int temp = 0;
        if((aft.get(Calendar.DAY_OF_MONTH) - bef.get(Calendar.DAY_OF_MONTH))>-1){
            temp = 1;
        }
        System.out.println(temp);
        System.out.println(Math.abs(month + result ) + temp);
      //  Date d1 = sf.parse(a);
      //  Date d2 = sf.parse(b);
      //  System.out.println(d1.getTime());
      //  System.out.println(d2.getTime());
     }
}
